import json
import pyttsx3

# 初始化TTS引擎
engine = pyttsx3.init()
engine.setProperty('rate', 150)  # 语速
engine.setProperty('volume', 0.9)  # 音量
data = []
with open("./data/train.jsonl", "r", encoding="utf-8") as f:
    lines = f.readlines()
    for line in lines:
        obj = json.loads(line)
        data.append(obj['conversation'][0]['human'])

for i, input_str in enumerate(data):
    engine.save_to_file(input_str, f"./data/audio/{i:02}.wav")

engine.runAndWait()

